﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace eHouse
{
    public partial class ScheduleIrrigation : PhoneApplicationPage
    {
        private System.Collections.ObjectModel.ObservableCollection<ItemViewModel> CurrentItemsForRule;

        public ScheduleIrrigation()
        {
            CurrentItemsForRule = new System.Collections.ObjectModel.ObservableCollection<ItemViewModel>();
            foreach (ItemViewModel i in App.ViewModel.LightItems)
            {
                CurrentItemsForRule.Add(new ItemViewModel()
                {
                    LineOne = i.LineOne
                });
            }

            InitializeComponent();
        }

        private void cancel_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
        }

        private void save_Click(object sender, RoutedEventArgs e)
        {
            Rule rule = new Rule();
            rule.Id = Guid.NewGuid().ToString();
            rule.Time = time.ValueString;
            rule.Data = state.IsChecked;
            App.RuleForSaving = rule;
            App.RuleAdderCall = App.ConnectionManager.AddIrrigationRule;

            NavigationService.GoBack();
        }
    }
}